<?php
	// start the session
	session_start(); 

	// include the ec2 class library
  	require_once("class.s3.php");
?> 
<!-- *+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+ -->
<!-- File: GetBuckets.php 																						-->
<!--																											-->
<!-- Author: John Fronckowiak, IDC Consulting, Inc.																-->
<!--																											-->
<!-- Purpose: Retrieve the available buckets.																	-->
<!-- *+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+ -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<!-- set the iPhone viewport -->
	<meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
	
	<!-- include the iui style sheet and javascript -->
	<style type="text/css" media="screen">@import "lib/iui/iui.css";</style>
    <script type="application/x-javascript" src="lib/iui/iui.js"></script>		

	<title>Amazon Web Services Manager</title>
</head>

<body>
<ul id="buckets" title="Your Buckets" selected="true">
<li class="group">Bucket Name</li>
<?php
	// create an S3 object
  	$s3 = new S3($HTTP_SESSION_VARS["AMAZON_KEY"], $HTTP_SESSION_VARS["AMAZON_PRIVATE_KEY"]);

	// retrieve the available buckets
  	$buckets = $s3->getBuckets();

	// are there any buckets?
  	if (count($buckets) == 0) {
      	echo "<li>There are no buckets available!</li>";
  	} else {
		// list each bucket - provide a menu link for each
      	foreach ($buckets as $bucket_name) {
          echo "<li><a href='#$bucket_name'>$bucket_name</a></li>";
    }
    echo "</ul>";

    // for each bucket
    foreach ($buckets as $bucket_name) {
		// create a menu for each bucket to retrieve the size, delete the bucket, and retrieve the contents
    	echo "<ul id='$bucket_name' title='Manage $bucket_name'>";
        echo "<li><a href='size.php?bucket=$bucket_name'>Size</a></li>";
        echo "<li><a href='delete.php?bucket=$bucket_name'>Delete</a></li>";
        echo "<li><a href='contents.php?bucket=$bucket_name'>Contents</a></li>";
        echo "</ul>";
     }
  }
?>
</body>
</html>